package com.example.tablistfractionzlw1002.slice;
import com.example.tablistfractionzlw1002.ResourceTable;
import ohos.agp.components.*;
import ohos.app.Context;

import java.util.List;

public class NEW_porive extends BaseItemProvider {
    List <Itme> list;
    Context context;

    public NEW_porive(List<Itme> list, Context context) {
        this.list = list;
        this.context = context;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int i) {
        return list.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public Component getComponent(int i, Component component, ComponentContainer componentContainer) {
        Component parse = LayoutScatter.getInstance(context).parse(ResourceTable.Layout_new_list, null, false);
        Itme itme=list.get(i);
        Text text= (Text) parse.findComponentById(ResourceTable.Id_txt);
        Image image= (Image) parse.findComponentById(ResourceTable.Id_pImage);
        text.setText(itme.getTitle());
        image.setImageAndDecodeBounds(itme.getImg());
        return parse;
    }
}
